﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace HiganUI
{
    using Ini;
    public partial class romPaths : Form
    {
        IniFile iniFile;
        public romPaths()
        {
            InitializeComponent();

            string p = System.Reflection.Assembly.GetExecutingAssembly().Location;
            iniFile = new IniFile( p.Substring( 0, p.Length - 3 ) + "ini" );
            SNES_path.Text =iniFile.IniReadValue( "rompaths", "SNES" );
            NES_path.Text = iniFile.IniReadValue( "rompaths", "NES" );
            GBA_path.Text = iniFile.IniReadValue( "rompaths", "GBA" );
            GB_path.Text = iniFile.IniReadValue( "rompaths", "GB" );

        }

        private void button1_Click( object sender, EventArgs e )
        {
            SNES_path.Text = romPaths_Load(SNES_path.Text);
        }

        private void button2_Click( object sender, EventArgs e )
        {
            NES_path.Text = romPaths_Load(NES_path.Text);
        }

        private void button4_Click( object sender, EventArgs e )
        {
            GBA_path.Text = romPaths_Load(GBA_path.Text);
        }

        private void button3_Click( object sender, EventArgs e )
        {
            GB_path.Text = romPaths_Load(GB_path.Text);
        }


        private void romPaths_Load( object sender, EventArgs e )
        {

        }
        private String romPaths_Load( string startUpFolder )
        {
            findFolder.SelectedPath = startUpFolder;


            if ( findFolder.ShowDialog() == DialogResult.OK )
            {
                try
                {
                    //if ( findFolder.SelectedPath != null )
                }
                catch ( Exception ex )
                {
                    MessageBox.Show( "Error: Could not read folder :" + ex.Message );
                }
            }

            return findFolder.SelectedPath;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            iniFile.IniWriteValue( "rompaths", "SNES", SNES_path.Text );
            iniFile.IniWriteValue( "rompaths", "NES", NES_path.Text );
            iniFile.IniWriteValue( "rompaths", "GBA", GBA_path.Text );
            iniFile.IniWriteValue( "rompaths", "GB", GB_path.Text );
        }
        private void btnCancel_Click( object sender, EventArgs e )
        {

        }


    }
}


